/*
 * Project: Hell Watch
 * Author: pajoke
 * Copyright: (C) 2014 Hell Prototypes
 * License: GNU GPL v3 (see License.txt)
 * Web: http://www.hellprototypes.com
 */

#ifndef MILLIS_H_
#define MILLIS_H_

/**
* Milliseconds data type \n
* Data type				- Max time span			- Memory used \n
* unsigned char			- 255 milliseconds		- 1 byte \n
* unsigned int			- 65.54 seconds			- 2 bytes \n
* unsigned long			- 49.71 days			- 4 bytes \n
* unsigned long long	- 584.9 million years	- 8 bytes
*/
typedef unsigned int millis_t;

typedef unsigned char millis8_t;

#ifndef ARDUINO
/**
* Alias of millis_get().
*
* @note Not availble for Arduino since millis() is already used.
*/
	#define millis() millis_get()
#endif

#define MILLIS_TIMER_EN()		(TCC1.CTRLA = 0x04)
#define MILLIS_TIMER_DIS()	(TCC1.CTRLA = 0x00)

/**
* Initialise, must be called before anything else!
*
* @return (none)
*/
void millis_init(void);

/**
* Get milliseconds.
*
* @return Milliseconds.
*/
millis_t millis_get(void);

void ms_delay(millis_t ms);


#endif /* MILLIS_H_ */